package project.fileAccess;
import project.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;

public class ListLocations{
    public static void main(String[] args) throws IOException {
        ArrayList<DatabaseInfo> dbList = new ArrayList<DatabaseInfo>();
		try
		{
		    FileInputStream fis = new FileInputStream("locations.dat");
	ObjectInputStream ois = new ObjectInputStream(fis);
        while(true){
        try{
    dbList.add((DatabaseInfo)ois.readObject());
        }catch (EOFException e){
            System.out.println("Locations:");
                System.out.println("Host\tPort No\tUsername\tDatabase");
                break;
        }
    }
 	ois.close();
		} catch (IOException e)	{
			System.err.println ("File not found.");
			System.exit(1);
		} catch (ClassNotFoundException e){
            System.exit(1);
        }
    for (int i=0;i<dbList.size();i++){
        dbList.get(i).displayInfo();
    }


  }
}
